#pragma once
#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <cerrno>
#include <cstring>
#include <fcntl.h>
#include <string>

#define FIFO_FILE "./myfifo"
#define MODE 0664
#define SIZE 1024

enum
{
    FILE_CREATE_ERR = 1,
    FILE_DELETE_ERR,
    FILE_OPEN_ERR,
    FILE_READ_ERR,
};

class Init
{
public:
    Init(){
        // 创建管道
        int n = mkfifo(FIFO_FILE, MODE);
        if (n == -1){
            perror("mkfifo");
            exit(FILE_CREATE_ERR);
        }
    }
    ~Init(){
        // 删除管道
        int m = unlink(FIFO_FILE);
        if (m == -1){
            perror("unlink");
            exit(FILE_DELETE_ERR);
        }
    }
};
